POV-Ray : Newsgroups : povray.advanced-users : friendly splines : Re: friendly splines Server Time
30 Jul 2024 10:22:26 EDT (-0400)
  Re: friendly splines  
From: Chris Colefax
Date: 16 Aug 1999 23:25:43
Message: <37b8d637@news.povray.org>
Rainer Mager <nos### [at] golcom> wrote:
>     I was wondering if anyone has any "friendly" spline INCs for POV. What
I
> mean is this. I'm looking for a spline generator that does things a bit
> differently from the current ones (at least the current ones that I know
> about).
>     The most important thing that I need is a way to travel along a spline
> in steady increments. With the current splines if you create 1 segment
that
> is relatively short and then one segment that is relatively long, when you
> travel along the short one you will be moving slowly and when you travel
> along the long one you will be moving quickly. I need to be able to travel
> at a user defined pace at any point along the spline. YES, I realize this
> can be done with the current splines but it seems to be pretty difficult
> calculations.
>     Second, I'd like to be able to define a spline via end-points only and
> then some sort of global "tightness" value. That way I just pick a bunch
of
> points I want the spline to pass though and a tightness to determine how
> floppy or tight the curves are.

I guess my Spline Generator is one of the unfriendly include files
mentioned, and I would be the first to agree that it is inadequate in so
many, many ways (although, with perhaps a touch of nostalgia, I'm quite
happy with the way I overcame POV-Ray 3.0's lack of arrays and macros....)

After much investigation into splines, I've now created a set of macros that
I think covers most bases - at the simplest level, you can specify a list of
points, and have these points interpolated smoothly given a value in the
range 0 (first point) to 1 (last point).  The first change, though, is that
each point is assigned a time value as well.  These times can be specified
manually; if not, each point is given a time value based on the length from
the previous point (relative to the length of the entire spline), so that if
you have two points quite close together, and a third point four times as
far away, you'll reach the second point at 0.2 (rather than at 0.5).

Secondly, you can optionally specify values for the spline tension (the
looseness/tightness you talked about), spline bias, and spline continuity:
in effect, you can create Catmull-Rom splines, Cardinal splines, Tau
splines, and Kochanek-Bartels splines (the first three being subsets of the
last).  Alternatively, you can create Bezier splines like the current Spline
include file, where only every third point is actually on the spline, or
Hermite splines (giving a list of control points and velocities/tangents to
interpolate).

With these two changes, though, the actual speed of the spline remains
dependent on the curvature (ie. the spline tends to slows down around tight
curves).  This is not wholly undesirable, but I've overcome it (for when
necessary) by first sampling the spline distance with respect to time, so
that you can then inversely evaluate the spline position, tangent, and
acceleration, given a distance along the spline (ie. you can move at a
constant speed along the length of the spline, or modify this linear
relationship so that you fully control the acceleration, etc).

As for actually using the splines - I've created macros that will
automatically animate an object (or camera) along the spline, changing its
pitch, yaw, and roll.  I am working on adding macros that will allow you to
add barrel rolls, waves, shakes, bounces, spins, and spirals, or various
combinations of all, to the movement, as desired.  I'm also working on
macros to create objects along the splines, ranging from the usual
cylinders, spheres, cones, and blobs, to linking various objects along a
spline, bending objects along a spline, extruding prisms along a spline,
etc.

Currently I am fine-tuning the sampling behaviour and syntax (although, if I
could permit myself another moment of immodesty, I'm quite pleased with the
way I've overcome POV-Ray's lack of support for arbitrary numbers of macro
options!).  Hopefully, then, the final result shall be announced some time
soon...


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.